from django.db import models

class User(models.Model):
    worker_number = models.CharField(max_length=30,unique=True)
    name = models.CharField(max_length=30,)
    email = models.EmailField()
    phone = models.CharField(max_length=30)
    enable = models.BooleanField(default=True)

class Error(models.Model):
    machine = models.CharField(max_length=200)
    content = models.CharField(max_length=200)
    department = models.CharField(max_length=30)
    countermeasure = models.TextField()
    status = models.CharField(max_length=200)
    error_time = models.CharField(max_length=200)
    enable = models.BooleanField(default=True)

class Trace(models.Model):
    sn = models.CharField(max_length=200,default='')
    machine = models.ForeignKey('Error',related_name='error_machine')
    date = models.DateTimeField()
    content = models.ForeignKey('Error',related_name='error_content')
    comfirm_man = models.ForeignKey('User',related_name='comfirm_man_id')
    liable_man = models.ForeignKey('User',related_name='liable_man_id')
    #is_check = models.IntegerField(default=0)
    is_check = models.BooleanField(default=False)
    #is_comfirm = models.IntegerField(default=0)
    is_comfirm = models.BooleanField(default=False)

    class Meta:
        unique_together = ('machine', 'date','content','comfirm_man','liable_man')